package com.lujieni.moon.config;

import com.lujieni.moon.filter.JWTVerifyGlobalFilter;
import com.lujieni.moon.utils.JWTUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author
 * @Title: GlobalFilterConfiguration
 * @Description:
 * @date 2022/10/20 10:08 下午
 */
@Configuration
public class GlobalFilterConfiguration {

    /**
     * 登录校验过滤器
     * @return
     * matchIfMissing = true 如果没有配置就默认创建bean
     */
    @Bean
    @ConditionalOnProperty(name = "filter.jwt.verify.global.enabled", matchIfMissing = false)
    public JWTVerifyGlobalFilter createJWTVerifyGlobalFilter(JWTUtils jwtUtils) {
        JWTVerifyGlobalFilter filter = new JWTVerifyGlobalFilter();
        filter.setJwtUtils(jwtUtils);
        return filter;
    }

}
